package leetcode.editor.cn;
//[55]跳跃游戏
public class JumpGame55{
public static void main(String[] args) {
   Solution solution = new JumpGame55().new Solution();
   
}

  //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    //执行耗时:2 ms,击败了93.92% 的Java用户
    public boolean canJump(int[] nums) {
        if (nums == null || nums.length < 1) return false;
        int len = nums.length;

        //int [] dp = new int[len];
        int accessMax = nums[0];
        for (int i = 1; i < len; i++) {
            if (accessMax >= i){//到达当前。
                accessMax = Math.max(accessMax, i+nums[i]);
                if (accessMax >= len-1 )return true;
            }
        }
        return accessMax >= len -1;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}